package com.hzdl.car.sqlprovider;

import com.hzdl.car.util.Common;
import com.hzdl.car.vo.MenuVo;
import org.apache.ibatis.jdbc.SQL;

public class MenuSqlProvider {
    public String findMenuBYWhere(MenuVo menuVo){
        return new SQL(){{

            SELECT("*");
            FROM("sys_menu");

           if(!Common.isEmpty(menuVo.getName())){
               WHERE("name like concat('%',#{name},'%')");
           }
           if(menuVo.getAvailable()!=null){
               WHERE("available=#{available}");
           }
        }}.toString();
    }

    public String findMenuById(MenuVo menuVo){
        return new SQL(){{
            SELECT("*");
            FROM("sys_menu");
            if(menuVo.getId()!=null&&menuVo.getId()!=1){
                WHERE("id=#{id} or pId=#{id}");
            }
        }}.toString();
    }
}
